/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Vista;

import Main.Empieza;
import Modelo.*;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
import javax.swing.*;

/**
 *
 * @author Roberth
 */
public class ComprarEntradaConUsuario extends javax.swing.JFrame implements Observer {

    public Pelicula peli;
    public Provincia provinc;
    public Cine cin;
    public Sala sal;
    public int fech;
    public Sesion sesi;
    public TicketCine tk;
    public ArrayList<Provincia> provincia;
    private GestorTicketCine gtc;
    private UsuarioRegistrado user;
    /**
     * Creates new form VentanaPrincipal
     */
    public ComprarEntradaConUsuario(GestorTicketCine gtc, UsuarioRegistrado u) {
        this.user = u;
        this.gtc = gtc;
        provincia = new ArrayList<>();
        //this.provincia = gtc.getTicketCine().getProvincias();

        usuario = new Usuario(gtc.getTicketCine());
        usuario.iniciarConsultar(provincia);
        initComponents();

        dia.addItem("Def");
        for (Integer i = 1; i <= 31; i++) {
            dia.addItem(i.toString());
        }

        anyo.addItem("Def");
        for (Integer i = 2014; i <= 2030; i++) {
            anyo.addItem(i.toString());
        }

        mes.addItem("Def");
        String[] meses = usuario.getMeses();
        for (Integer i = 0; i <= meses.length - 1; i++) {
            mes.addItem(meses[i]);
        }

//        for( Object p : peliculas ){
//            pelicula.addItem(p.toString());
//        }
//        for( Object c : cines ){
//            cine.addItem(c.toString());
//        }
        provincias.addItem("Default");
        for (Object pr : provincia) {
            provincias.addItem(pr.toString());
        }

        // provincias.addItem("Default");
        //for( Object pr : provincia ){
        //    provincias.addItem(pr.toString());
        //}
//        for( Object s : sesiones ){
//            jcSesion.addItem(s.toString());
//        }
//        GestorEventos.getInstance().suscribir(this,"Cambios");
        pack();

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jcnumEntradas = new javax.swing.JComboBox();
        dia = new javax.swing.JComboBox();
        mes = new javax.swing.JComboBox();
        anyo = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        cine = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        pelicula = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jcSesion = new javax.swing.JComboBox();
        jbContinuar = new javax.swing.JButton();
        provincias = new javax.swing.JComboBox();
        jcSala = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        NumEntradas = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Entrada");

        jLabel1.setText("Elegir fecha:");

        jLabel3.setText("Número de entradas:");

        jcnumEntradas.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0" }));
        jcnumEntradas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcnumEntradasActionPerformed(evt);
            }
        });

        dia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                diaActionPerformed(evt);
            }
        });

        mes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mesActionPerformed(evt);
            }
        });

        anyo.setToolTipText("");
        anyo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                anyoActionPerformed(evt);
            }
        });

        jLabel4.setText("Provincia");

        jLabel5.setText("Cine:");

        cine.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cineActionPerformed(evt);
            }
        });

        jLabel6.setText("Pelicula:");

        pelicula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peliculaActionPerformed(evt);
            }
        });

        jLabel7.setText("Sesión:");

        jcSesion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcSesionActionPerformed(evt);
            }
        });

        jbContinuar.setText("Continuar");
        jbContinuar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbContinuarActionPerformed(evt);
            }
        });

        provincias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                provinciasActionPerformed(evt);
            }
        });

        jcSala.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcSalaActionPerformed(evt);
            }
        });

        jLabel8.setText("Sala:");

        jLabel2.setText("Entradas disponibles :");

        NumEntradas.setEditable(false);
        NumEntradas.setText("Nº Entradas");
        NumEntradas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NumEntradasActionPerformed(evt);
            }
        });
        NumEntradas.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                NumEntradasPropertyChange(evt);
            }
        });

        jButton1.setText("Cancelar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel9.setText("( Comprar con Usuario )");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel3)
                            .addComponent(jLabel1)
                            .addComponent(jLabel9))
                        .addGap(22, 22, 22)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(dia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(mes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(anyo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(pelicula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cine, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(provincias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jcnumEntradas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton1))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jbContinuar)
                                .addGap(41, 41, 41))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jcSala, javax.swing.GroupLayout.Alignment.LEADING, 0, 58, Short.MAX_VALUE)
                                    .addComponent(jcSesion, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(18, 18, 18)
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(NumEntradas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(28, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(dia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(anyo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(provincias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(cine, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(pelicula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jcSala, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addGap(11, 11, 11)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jcSesion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jcnumEntradas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1)
                            .addComponent(jLabel9))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGap(184, 184, 184)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(NumEntradas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jbContinuar)
                        .addGap(20, 20, 20))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void provinciasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_provinciasActionPerformed
        ArrayList<Modelo.Cine> cines_loc = new ArrayList<Modelo.Cine>();
        String provincia1 = (String) provincias.getSelectedItem();
        //System.out.println(provincia1);
        cines_loc = usuario.buscarCinesPorProvincia(provincia1);
        cine.removeAllItems();
        for (Object c : cines_loc) {
            cine.addItem(c.toString());
        }

    }//GEN-LAST:event_provinciasActionPerformed

    private void cineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cineActionPerformed

        ArrayList<Pelicula> peliculas_loc = new ArrayList<>();
        String cine1 = (String) cine.getSelectedItem();
        String provincia1 = (String) provincias.getSelectedItem();

        //System.out.println(cine1);
        peliculas_loc = usuario.buscarPeliculasPorProvinciaYCine(provincia1, cine1);
        pelicula.removeAllItems();

        for (Object p : peliculas_loc) {
            pelicula.addItem(p.toString());
        }

    }//GEN-LAST:event_cineActionPerformed

    private void peliculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peliculaActionPerformed
        // TODO add your handling code here:
        ArrayList<Sala> sala_loc = new ArrayList<>();
        String pelicula1 = (String) pelicula.getSelectedItem();
        String cine1 = (String) cine.getSelectedItem();
        String provincia1 = (String) provincias.getSelectedItem();
        //System.out.println(cine1);

        sala_loc = usuario.buscarSalaPorProvinciaPeliYCine(provincia1, pelicula1, cine1);
        jcSala.removeAllItems();
        for (Object p : sala_loc) {
            jcSala.addItem(p.toString());
        }

    }//GEN-LAST:event_peliculaActionPerformed

    private void jbContinuarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbContinuarActionPerformed

        ArrayList<Sala> sala_loc = new ArrayList<>();
        String pelicula1 = (String) pelicula.getSelectedItem();
        String cine1 = (String) cine.getSelectedItem();
        String provincia1 = (String) provincias.getSelectedItem();
        String sala1 = (String) jcSala.getSelectedItem();
        String sesion1 = (String) jcSesion.getSelectedItem();
        String dia1 = (String) dia.getSelectedItem();
        String mes1 = String.valueOf(mes.getSelectedIndex());
        String anyo1 = (String) anyo.getSelectedItem();
        int fecha;
        Sesion sesion;
        EntradaParaUsuario entradaUser;
        fecha = convertirFecha(dia1, mes1, anyo1);
        sala_loc = usuario.buscarSalaPorProvinciaPeliYCine(provincia1, pelicula1, cine1);
        for (Sala p : sala_loc) {

            if (sala1.equals(p.getNombreSala())) {

                for (Sesion s : p.getSesions()) {

                    if (sesion1.equals(s.toString())) {
                        
                        s.addEntrada(pelicula1, fecha, jcnumEntradas.getSelectedIndex(), p.getCapacidad_sala());
                        int butacas_disp = s.n_butacas_Disponibles(pelicula1, fecha);
                        NumEntradas.setText("" + butacas_disp);
                        jcnumEntradas.removeAllItems();
                        sesion = s;
                            
                        for (int i = 0; i <= butacas_disp; i++) {
                            jcnumEntradas.addItem("" + i);
                        }

                    }
                }
            }
        }

        if (dia1 == "Def" || mes1 == "Def" || anyo1 == "Def" || provincias.getSelectedItem() == "Default") {
            cont = JOptionPane.showConfirmDialog(null, "Falta algun campo por rellenar",
                    "", JOptionPane.CLOSED_OPTION);
        } else {
            cont = JOptionPane.showConfirmDialog(this, "Pagar",
                    "Pasarela de pago",
                    JOptionPane.YES_NO_OPTION);

            if (cont == 0) {
                
                user.addCriticas(new Critica(pelicula1, fecha, "No critica encontrada"));
                user.addEntrada(new EntradaParaUsuario(pelicula1, fecha, sesion1 ));
                
                tk = usuario.getTicketCine();
                tk.setProvincias(provincia);
                
                tk.addUsuarioregistrados(user);
                
                usuario.setTicketCine(tk);
                usuario.setGestorTicketCine(gtc);
                gtc.realizarBackup();

            }
        }


    }//GEN-LAST:event_jbContinuarActionPerformed

 private int convertirFecha(String dia, String mes, String anyo) {
        
        int fech = Integer.parseInt(dia)  + Integer.parseInt(mes) * 100 + Integer.parseInt(anyo) * 10000;
        
        return fech;
    }

    private void jcSalaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcSalaActionPerformed
        ArrayList<Sesion> sala_loc = new ArrayList<>();
        String sala1 = (String) jcSala.getSelectedItem();
        String cine1 = (String) cine.getSelectedItem();
        String provincia1 = (String) provincias.getSelectedItem();

        //System.out.println(cine1);
        sala_loc = usuario.buscarSesionesPorProvinciaCineYSala(provincia1, cine1, sala1);
        jcSesion.removeAllItems();
        for (Object p : sala_loc) {
            jcSesion.addItem(p.toString());
        }
    }//GEN-LAST:event_jcSalaActionPerformed

    private void NumEntradasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NumEntradasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_NumEntradasActionPerformed

    private void NumEntradasPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_NumEntradasPropertyChange
        // TODO add your handling code here:
    }//GEN-LAST:event_NumEntradasPropertyChange

    private void jcSesionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcSesionActionPerformed
        ArrayList<Sala> sala_loc = new ArrayList<>();
        String sala1 = (String) jcSala.getSelectedItem();
        String pelicula1 = (String) pelicula.getSelectedItem();
        String cine1 = (String) cine.getSelectedItem();
        String provincia1 = (String) provincias.getSelectedItem();
        String sesion1 = (String) jcSesion.getSelectedItem();
        //System.out.println(cine1);

        String dia1 = (String) dia.getSelectedItem();
        String mes1 = String.valueOf(mes.getSelectedIndex());
        String anyo1 = (String) anyo.getSelectedItem();
        int fech = convertirFecha(dia1, mes1, anyo1);
        sala_loc = usuario.buscarSalaPorProvinciaPeliYCine(provincia1, pelicula1, cine1);

        //sala_loc = usuario.buscarSesionesPorProvinciaCineYSala(provincia1, cine1, sala1);
        for (Sala p : sala_loc) {
            if (p.getNombreSala().equals((String) jcSala.getSelectedItem())) {

                NumEntradas.setText("" + p.n_butacas_disp(sesion1, pelicula1, fech));
                jcnumEntradas.removeAllItems();
                for (int i = 0; i <= p.n_butacas_disp(sesion1, pelicula1, fech); i++) {
                    jcnumEntradas.addItem("" + i);
                }
            }
        }

    }//GEN-LAST:event_jcSesionActionPerformed

    private void jcnumEntradasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcnumEntradasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcnumEntradasActionPerformed

    private void diaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_diaActionPerformed
        dia.getSelectedItem();

        provincias.removeAllItems();
        provincias.addItem("Default");
        for (Object pr : provincia) {
            provincias.addItem(pr.toString());
        }
    }//GEN-LAST:event_diaActionPerformed

    private void mesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mesActionPerformed

        provincias.removeAllItems();
        provincias.addItem("Default");
        for (Object pr : provincia) {
            provincias.addItem(pr.toString());
        }

    }//GEN-LAST:event_mesActionPerformed

    private void anyoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_anyoActionPerformed

        provincias.removeAllItems();
        provincias.addItem("Default");
        for (Object pr : provincia) {
            provincias.addItem(pr.toString());
        }

    }//GEN-LAST:event_anyoActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        this.dispose();
        ControlAcceso v_CA = new ControlAcceso(gtc);
        v_CA.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

//    /**
//     * @param args the command line arguments
//     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(ComprarEntrada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(ComprarEntrada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(ComprarEntrada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(ComprarEntrada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new ComprarEntrada().setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField NumEntradas;
    private javax.swing.JComboBox anyo;
    private javax.swing.JComboBox cine;
    private javax.swing.JComboBox dia;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JButton jbContinuar;
    private javax.swing.JComboBox jcSala;
    private javax.swing.JComboBox jcSesion;
    private javax.swing.JComboBox jcnumEntradas;
    private javax.swing.JComboBox mes;
    private javax.swing.JComboBox pelicula;
    private javax.swing.JComboBox provincias;
    // End of variables declaration//GEN-END:variables
    private GestorTicketCine ticketCine;
    private Usuario usuario;
    private int cont = 1;

    @Override
    public void update(Observable o, Object arg) {
        JOptionPane.showMessageDialog(this, (String) arg, "Aviso", JOptionPane.WARNING_MESSAGE);
    }
}
